<template>
	<view class="home-hot">
		<view class="cell-1">
			<view class="title">热卖爆款</view>
			<view class="tips" @click="handleMore">
				<text>更多</text>
				<u-icon name="arrow-right" color="rgba(135, 135, 135, 1)" size="14"></u-icon>
			</view>
		</view>

		<scroll-view scroll-x="true" class="scroll-x">
			<view>
				<view class="list">
					<view class="list-item" v-for="(item,index) in listData" :key="index" @click="handleDetails(item)">
						<image :src="item.goodsPicAddress" mode="aspectFill"></image>
						<view class="text">{{item.goodsName}}</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>
<script>
	import {
		listHotApi
	} from "@/culturalCreativity/http/home.js";
	import {
		realmName
	} from "@/http";
	export default {
		data() {
			return {
				listData: [],
			}
		},
		methods: {
			async init() {
				let res = await listHotApi({
					id: 1,
					pageNum: 1,
					pageSize: 5
				});
				this.listData = res.data.rows.map(item => {
					item.goodsPicAddress = `${realmName}${item.goodsPicAddress.split(",")[0]}`;
					return item;
				});
			},
			handleDetails(options){
				uni.navigateTo({
					url:"/culturalCreativity/common/shoppingDetails?id="+options.goodsId
				});
			},
			async handleMore() {
				uni.setStorageSync('PAGE_DATA', {
					title: "热卖爆款",
					fileName: "home-hot"
				});
				uni.navigateTo({
					url: "/culturalCreativity/classification/detailsList"
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.home-hot {
		background: #FFFFFF;
		border-radius: 30rpx;
		padding: 24rpx 0;

		.cell-1 {
			padding: 0 24rpx;
			display: flex;
			justify-content: space-between;

			.title {
				color: rgba(253, 143, 25, 1);
				font-size: 32rpx;
			}

			.tips {
				display: flex;
				align-items: center;

				text {
					font-size: 24rpx;
					color: rgba(135, 135, 135, 1);
					margin-left: 8rpx;
				}
			}
		}

		.list {
			display: flex;
			margin-top: 24rpx;
			padding-left: 24rpx;

			.list-item {
				padding-right: 24rpx;

				image {
					width: 207rpx;
					height: 207rpx;
					border-radius: 16rpx;
				}

				.text {
					margin-top: 12rpx;
					color: rgba(31, 31, 31, 1);
					font-size: 24rpx;
					width: 100%;
					display: -webkit-box;
					overflow: hidden;
					text-overflow: ellipsis;
					word-wrap: break-word;
					white-space: normal !important;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
				}
			}
		}

		.scroll-x {
			width: 100%;
			height: 280rpx;
		}
	}
</style>
